﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass()]
public class TripleExtractUtilitiesTest
{
    public static bool AreStringArraysEqual(string[] arr1, string[] arr2)
    {
        if (arr1.Length!=arr2.Length)
        {
            return false;
        }
        for (int i = 0; i < arr1.Length; i++)
        {
            if (arr1[i]!=arr2[i])
            {
                return false;
            }
        }
        return true;
    }

    [TestMethod()]
    public void GetTriplesFromStringTest()
    {
        string input = "This is a list of triples: (1, 2, 3); (22,33,44) and (1,2,3). This is not a triple: (1,2). "+
            "This is also not a triple: [1,2,3]. Not that this is triple: ( 1, 2, 3 ).";
        string[] expected = new string[]{ "(1, 2, 3)", "(22,33,44)", "(1,2,3)" };
        string[] actual = TripleExtractUtilities.GetTriplesFromString(input);
        Assert.IsTrue(AreStringArraysEqual(expected, actual));
    }

    [TestMethod()]
    public void GetTriplesFromStringNegativeNumbers()
    {
        string input = "This is a list of triples: (1, -2, 3); (22,33,44) and (1,2,3). This is not a triple: (1,2). " +
            "This is also not a triple: [1,2,3]. Not that this is triple: ( 1, 2, 3 ).";
        string[] expected = new string[] { "(1, -2, 3)", "(22,33,44)", "(1,2,3)" };
        string[] actual = TripleExtractUtilities.GetTriplesFromString(input);
        Assert.IsTrue(AreStringArraysEqual(expected, actual));
    }

    [TestMethod()]
    public void GetTriplesFromStringFullNegativeNumbers()
    {
        string input = "This is a list of triples: (1, -2, 3); (22,-33,44) and (-1,2,3). This is not a triple: (1,2). " +
            "This is also not a triple: [1,2,3]. Not that this is triple: ( -1, 2, -3 ).";
        string[] expected = new string[] { "(1, -2, 3)", "(22,-33,44)", "(-1,2,3)" };
        string[] actual = TripleExtractUtilities.GetTriplesFromString(input);
        Assert.IsTrue(AreStringArraysEqual(expected, actual));
    }
}